/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controllers;

import BO.Transfer;
import Dao.TransferDao;
import Exceptions.BusinessException;
import Exceptions.DataAccessException;
import java.io.IOException;
import java.util.List;
/**
 *
 * @author Bruno Lopes
 */
public class TransferController {

    public TransferController() {
    }

    public static void criarTransporte(int tipoTr, int vacancies,
            String nomeComp, String destino) throws BusinessException,
            DataAccessException, IOException, ClassNotFoundException {
        
         //Faltam as verificações

        Transfer transport = new Transfer();
        transport.setTransferType(tipoTr);
        transport.setSeats(vacancies);
        transport.setTransferCompany(nomeComp);
        transport.setDestination(destino);

        List<Transfer> lista = TransferDao.getAll();

        if (lista.contains(transport)) {
            throw new BusinessException("Já existe um transporte com os"
                    + " dados inseridos");
        } else {
            int rows = TransferDao.criar(transport);
            System.out.println("\n" + rows + " Rows afected.");
        }
    }

    public static void alterarDadosId(int id) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
